define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'business/index',
        add_url: 'business/add',
        edit_url: 'business/edit',
        delete_url: 'business/delete',
        export_url: 'business/export',
        modify_url: 'business/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh', 'add', 'delete'],
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: '商家ID'},
                    {field: 'user_id', title: '用户ID'},
                    {field: 'phone', title: '联系电话'},
                    /*{field: 'password', title: 'password'},*/
                    {
                        field: 'status', title: '状态', selectList: ['待审核', '已通过', '已拒绝'], templet: function (k, v) {
                            switch (k.status) {
                                case 1:
                                    return '<span class="layui-badge layui-bg-green">已通过</span>';
                                    break;
                                case 2:
                                    return '<span class="layui-badge">已拒绝</span>';
                                    break;
                                default:
                                    return '<span class="layui-badge layui-bg-gray">待审核</span>';
                                    break;
                            }
                            console.log(k, v);
                        }
                    },
                    {field: 'contacts', title: '联系人'},
                    {field: 'shop_name', title: '店铺名称'},
                    {field: 'address', title: '地址'},
                    {field: 'create_time', title: '创建时间', width: 200, search: 'range'},
                    {width: 250, title: '操作', templet: ea.table.tool},
                ]],
                done: function () {
                    $(".layui-table-body>table>tbody>tr").each(function (index, val) {
                        $($(".layui-table-fixed .layui-table-body table tr")[index]).height($(val).height());
                    });
                },
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});